<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Signin Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="bootstrap_sign_in.css" rel="stylesheet">
  </head>

  <body class="text-center">
    <form class="form-signin">
      <img class="mb-4" src="bootstrap-solid.svg" alt="" width="24" height="24">
      <h1 class="h3 mb-3 font-weight-normal"  onclick="clickprompt();">拦截prompt调用Android端方法</h1>
      <label for="inputEmail" class="sr-only">Email address</label>
      <input type="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
      <label for="inputPassword" class="sr-only">Password</label>
      <input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
      <div class="checkbox mb-3">
        <label>
          <input type="checkbox" value="remember-me" onchange="toggleCheckbox(this)">响应服务端的alert
        </label>
      </div>
      <button class="btn btn-lg btn-primary btn-block" type="submit" onclick="callAndroid()">注解调用Android端方法1</button>
      <p class="text-muted"><a href="javascript:window.external.showA('js调用Android中的showB方法');">注解调用Android端方法2</a></p>

      <p class="text-muted"><a href="js://method1?arg1=111&arg2=222">拦截url调用Android端方法1</a></p>

      <p class="text-muted"><a href="js://method2?arg1=中国&arg2=天数奇谭">拦截url调用Android端方法2</a></p>

      <p class="text-muted"><a href="https://blog.csdn.net/cdc_csdn/article/details/80715296">博客地址</a></p>
    </form>

    <script>
      function toggleCheckbox(element){
        var aa=element.checked;
        var s=aa ? "选中了" : "取消了";
        alert(s);
      }

    //Android需要调用的方法
   function callJs(str){
      alert("Android调用了JS的callJS方法,获得来自Android端的数据:"+str);
   }

    //Android需要调用的方法
   function callJsByEval(str){
      alert("Android调用了JS的callJS方法,获得来自Android端的数据:"+str);
      return "js 返给 Android";
   }

    function callAndroid(){
       external.showA("js调用了android中的showA方法");
    }

   function clickprompt(){
    // 调用prompt（）
    var result=prompt("js://prompt?arg1=111&arg2=222");
    alert(result);
}
    </script>
  </body>
</html>
